import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DisciplineVO, DisciplineForm, DisciplineQuery } from '@/api/school/discipline/types';

/**
 * 查询学科管理列表
 * @param query
 * @returns {*}
 */

export const listDiscipline = (query?: DisciplineQuery): AxiosPromise<DisciplineVO[]> => {
  return request({
    url: '/school/discipline/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询学科管理详细
 * @param disciplineId
 */
export const getDiscipline = (disciplineId: string | number): AxiosPromise<DisciplineVO> => {
  return request({
    url: '/school/discipline/' + disciplineId,
    method: 'get'
  });
};

/**
 * 新增学科管理
 * @param data
 */
export const addDiscipline = (data: DisciplineForm) => {
  return request({
    url: '/school/discipline',
    method: 'post',
    data: data
  });
};

/**
 * 修改学科管理
 * @param data
 */
export const updateDiscipline = (data: DisciplineForm) => {
  return request({
    url: '/school/discipline',
    method: 'put',
    data: data
  });
};

/**
 * 删除学科管理
 * @param disciplineId
 */
export const delDiscipline = (disciplineId: string | number | Array<string | number>) => {
  return request({
    url: '/school/discipline/' + disciplineId,
    method: 'delete'
  });
};
